var arr  = [1, 5, 3]
var str = new String("hello")
/*
// 屏蔽 arr实例的 [Symbol.iterator] 方法
arr[Symbol.iterator] = function() {
	console.log(this)
	return {value: 10, done:false, next: function(v) {
		console.log(v)
	}}
}

// Result of the Symbol.iterator method is not an object
for(var i of arr) {
}

*/


// 生成一个迭代器对象
function makeIterator(arr) {
	var index = 0 ;
	return {
		next() {
			if(index < arr.length) {
				return {value: arr[index++], done: false}
			}
			return {value:undefined, done:true} 
		}
	}
}

var it = makeIterator(arr)
console.log(it.next())
console.log(it.next())
console.log(it.next())
console.log(it.next())
console.log(it.next())
console.log('-----------------------------\n')
var it = arr[Symbol.iterator]()
console.log(it.next())
console.log(it.next())
console.log(it.next())
console.log(it.next())
console.log(it.next())



